using System;
using System.Collections;
using System.Xml;
using InfoJetSoft.Service.Entity;
using InfoJetSoft.Service.Util;

namespace InfoJetSoft.Service.Worker
{
	/// <summary>
	/// Summary description for FormDataObjectLoadWorker.
	/// </summary>
	class FormDataRefreshWorker
	{
		public static void refresh( Form form, string auxDom ){
			if( auxDom == null || auxDom.Length <= 0 ){
				return;
			}
			//CID 0474 //2009.12.23 //Begin
			form.Logger.LogUpdate(null);
			//CID 0474 //2009.12.23 //End
			foreach( DataObject dataObject in form.Manifest.DataObjectList )
			{
				try
				{
					if( dataObject.Name.Equals( auxDom ) )
					{
						if( dataObject.WSAdapter != null )
						{
							DataWSAdapter wsAdapter = (DataWSAdapter)DataAdapterTableUtil.getAvaliableAdapter( form, dataObject.WSAdapter );
							DataObjectWSLoadWorker.loadWSDataObject( form, dataObject, wsAdapter );
						}
						break;
					}
				}
				catch( Exception e )
				{
					FormUtil.addModalMessage( form,  MessageUtil.Error2Refresh() + auxDom, e, dataObject.WSAdapter != null );
				}
			}
		}
	}
}
